package think.in.java.concurrency.practise.exec2;

import think.in.java.concurrency.practise.exec1.ExcOne;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 5/19/11
 * Time: 12:09 AM
 * simple sample for the thread pool
 */
public class ForExecutor{
    public static void main(String[] args){
        ExecutorService executor =  Executors.newCachedThreadPool();
        for(int i=0;i<10;i++){
            //put in the runnable object
            executor.execute(new ExcOne("newCachedThreadPool"));
        }

        ExecutorService executorService2 = Executors.newFixedThreadPool(5);
        for(int i=0;i<10;i++){
            executorService2.execute(new ExcOne("newFixedThreadPool"));
        }
    }
}
